-module(toplevel).
-compile(export_all).

connect(ID) ->
    toplevel ! {add, ID, self(), {}},
    receive
	_ -> ok
    end.

dialog(ID, Message) ->
    toplevel ! {talk, ID, self(), {Message}},
    Pretty = receive
		 {ok, Out} -> {"> ", Out};
		 error -> {"XX", "Une erreur est survenue, rafraichissez la page"}
	     end,
    [ {"# ", Message}, Pretty].

disconnect(ID) ->
    toplevel ! {remove, ID, self(), {}},
    receive
	_ -> ok
    end.
